
### Local Economic Voting and the Agricultural Boom in Argentina
### Maria V. Murillo, Jorge Mangonnet, and Julia Rubio
### Replication: Supplementary materials
### February, 2018


rm(list=ls()) # clear all objects in memory
dev.off()     # reload graphic device

if (!require("pacman")) install.packages("pacman")   # load packages
pacman::p_load(
  arm, 
  foreign, 
  car, 
  sandwich, 
  lmtest, 
  dplyr, 
  plyr, 
  magrittr, 
  ggplot2, 
  gridExtra,
  maptools, 
  spdep, 
  spgwr, 
  rgdal, 
  sp,
  Matrix,
  RColorBrewer,
  xtable,
  stargazer,
  classInt,
  devEMF,
  lme4)


setwd("")   # set your working directory

cat("\014") # clear console


###################################################
#### Section 1: Load data and recode variables ####
###################################################

avr = 
  read.csv("LEVdbase.csv",
           header=TRUE, 
           stringsAsFactors=TRUE, 
           na.strings = ".") %>%  
  as.data.frame()

dplyr::glimpse(avr)  # look at the data

avr[is.na(avr)] = 0 # convert NAs o 0s

recoded = group_by(avr, no) %>% # subset data and recode
  summarise(
    # ids
    #no = no,
    # Soybean variables per season (harvest, planted, product, yield)
    soy_hvst_2015 = log(soja_cosecha_1415+1), # 2014/2015
    soy_hvst_2013 = log(soja_cosecha_1213+1), # 2012/2013
    soy_hvst_2011 = log(soja_cosecha_1011+1), # 2010/2011
    soy_hvst_2009 = log(soja_cosecha_0809+1), # 2008/2009
    soy_hvst_2007 = log(soja_cosecha_0607+1), # 2006/2007
    soy_plnt_2015 = log(soja_siembra_1415+1), # 2014/2015
    soy_plnt_2013 = log(soja_siembra_1213+1), # 2012/2013
    soy_plnt_2011 = log(soja_siembra_1011+1), # 2010/2011
    soy_plnt_2009 = log(soja_siembra_0809+1), # 2008/2009
    soy_plnt_2007 = log(soja_siembra_0607+1), # 2006/2007
    soy_prod_2015 = log(soja_producto_1415+1), # 2014/2015
    soy_prod_2013 = log(soja_producto_1213+1), # 2012/2013
    soy_prod_2011 = log(soja_producto_1011+1), # 2010/2011
    soy_prod_2009 = log(soja_producto_0809+1), # 2008/2009
    soy_prod_2007 = log(soja_producto_0607+1), # 2006/2007
    soy_ylds_2015 = log(soja_rinde_1415+1), # 2014/2015
    soy_ylds_2013 = log(soja_rinde_1213+1), # 2012/2013
    soy_ylds_2011 = log(soja_rinde_1011+1), # 2010/2011
    soy_ylds_2009 = log(soja_rinde_0809+1), # 2008/2009
    soy_ylds_2007 = log(soja_rinde_0607+1), # 2006/2007
    # Alternative explanations 
    lockouts_ln = log(lockouts_n+1), # 2008 farm ockouts
    k_intense = mq_sembradoras_eap / eap, # seed drills
    eap_small = (eap_hasta5_has + eap_5_10_has + eap_10_25_has) / eap_has, # smallholding farms (small EAPs, < 25 ha)
    # Controls
    eap_ln = log(eap+1), # number of farms
    education_01 = (educ_college_01 + educ_college_inc_01 + educ_mschool_01) / population15_01, # education 2001
    education_10 = (educ_college_10 + educ_college_inc_10 + educ_mschool_10) / population15_10, # education 2010
    poverty_01 = nbi_01 / population_01, # poverty 2001
    poverty_10 = nbi_10 / (nbi_10 + sin_nbi_10), # poverty 2010
    rural_10 = hh_rural_10 / hh_10, # rural population 2010
    rural_01 = population_rural_01 / population_01, # rural population 2001
    popdens_01 = log(population15_01 / area), # population density 2001
    popdens_10 = log(population15_10 / area) # population density 2010
  )

is.nan.data.frame <- function(x) do.call(cbind, lapply(x, is.nan)) # for the NaNs
recoded[is.nan(recoded)] <- 0

recoded <- do.call(data.frame, lapply(recoded, function(x) replace(x, is.infinite(x), 0))) # for the Infs

avr <- merge(avr, recoded, by='no') # merge
remove(recoded)

c2_prov = # import province-level variables
  read.csv("LEVprovince_C2.csv", 
           header=TRUE, 
           stringsAsFactors=TRUE, 
           na.strings = ".") %>%  
  as.data.frame()

avr <- merge(avr, c2_prov, by="id_p")



##############################################################
#### Section 2: Create spatial object and merge with data ####
##############################################################

options(warn=-1) 
avr_shp <- readOGR(    # read shape file 
  dsn=path.expand(""), # type the full directory, otherwise readOGR won't work
  layer="LEVspatial") 

plot(avr_shp) # plot it

avr_shp@data <- # join data frame and spatial object together
  data.frame(avr_shp@data, 
             avr[match(avr_shp@data[,"ID_2"], 
                       avr[,"id_d"]),]) 

names(avr_shp) # all merged

writeOGR(avr_shp, 
         layer="avr_shp", 
         dsn=path.expand(""), # type the full directory in dsn
         driver="ESRI Shapefile", 
         overwrite_layer=TRUE)

avr_shp <- avr_shp[!is.na(avr_shp@data$pro_pres1_2015) ,] # remove 4 departments w/ NAs in electoral outcomes

neighbors <- poly2nb(avr_shp, queen=TRUE) # create neighbor list (simple contiguity queen matrix)

wtm <- nb2listw(neighbors, zero.policy=TRUE) # set up queen matrix of spatial weights 


##############################################
#### Section 3: Materials in the appendix ####
##############################################

#### A. Additional Figures and Tables ####

## Multiple plot function for ggplot

# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols:   Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
#
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
# then plot 1 will go in the upper left, 2 will go in the upper right, and
# 3 will go all the way across the bottom.
#
multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) {
  library(grid)
  
  # Make a list from the ... arguments and plotlist
  plots <- c(list(...), plotlist)
  
  numPlots <- length(plots)
  
  # If layout is NULL, then use 'cols' to determine layout
  if (is.null(layout)) {
    # Make the panel
    # ncol: Number of columns of plots
    # nrow: Number of rows needed, calculated from # of cols
    layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
                     ncol=cols, nrow=ceiling(numPlots/cols))
  }
  
  if (numPlots==1) {
    print(plots[[1]])
    
  } else {
    # Set up the page
    grid.newpage()
    pushViewport(viewport(layout=grid.layout(nrow(layout), ncol(layout))))
    
    # Make each plot, in the correct location
    for (i in 1:numPlots) {
      # Get the i,j matrix positions of the regions that contain this subplot
      matchidx = as.data.frame(which(layout==i, arr.ind=TRUE))
      
      print(plots[[i]], vp=viewport(layout.pos.row=matchidx$row,
                                    layout.pos.col=matchidx$col))
    }
  }
}


## Figure A1: Scatterplots of vote shares against soybean harvests, 2007-2015 ----

par(mfrow=c(4,2))

# FPV 2007
png(file="A1l1.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2007, avr$fpv_dip_2007,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2007 (ln)", ylab="Vote (%)",
     main="FPV 2007", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$fpv_dip_2007 ~ avr$soy_hvst_2007))
dev.off()

# FPV 2009
png(file="A1l2.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2009, avr$fpv_dip_2009,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2009 (ln)", ylab="Vote (%)",
     main="FPV 2009", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$fpv_dip_2009 ~ avr$soy_hvst_2009))
dev.off()

# FPV 2011
png(file="A1l3.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2011, avr$fpv_dip_2011,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2011 (ln)", ylab="Vote (%)",
     main="FPV 2011", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$fpv_dip_2011 ~ avr$soy_hvst_2011))
dev.off()

# FPV 2013
png(file="A1l4.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2013, avr$fpv_dip_2013,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2013 (ln)", ylab="Vote (%)",
     main="FPV 2013", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$fpv_dip_2013 ~ avr$soy_hvst_2013))
dev.off()

# FPV 2015
png(file="A1l5.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2015, avr$fpv_dip_2015,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2015 (ln)", ylab="Vote (%)",
     main="FPV 2015", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$fpv_dip_2015 ~ avr$soy_hvst_2015))
dev.off()

# FPV 2011
png(file="A1p1.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2011, avr$fpv_pres_2011,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2011 (ln)", ylab="Vote (%)",
     main="FPV 2011", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$fpv_pres_2011 ~ avr$soy_hvst_2011))
dev.off()

# FPV 2015
png(file="A1p2.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2015, avr$fpv_pres1_2015,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2015 (ln)", ylab="Vote (%)",
     main="FPV 2015", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$fpv_pres1_2015 ~ avr$soy_hvst_2015))
dev.off()

# Cambieoms 2015
png(file="A1p3.png", units="in", width=5, height=5, res=300)
plot(avr$soy_hvst_2015, avr$pro_pres1_2015,
     xlim=c(.5,13.6), ylim=c(min(avr$fpv_dip_2013), max(avr$fpv_dip_2013)), 
     xlab="Soybean harvest 2015 (ln)", ylab="Vote (%)",
     main="Cambiemos 2015", cex=1.5, cex.main=1.5, cex.lab=1.6,
     frame.plot=FALSE, xaxs="i", pch=16)
abline(lm(avr$pro_pres1_2015 ~ avr$soy_hvst_2015))
dev.off()


## Figure A2: Spatial distribution of the vote, 2007-2015 ----

palette_fpv <- brewer.pal(n=7, name="Blues")
palette_pro <- brewer.pal(n=7, name="Oranges") # assign color palette

# FPV 2007
png(file="A2l1.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "fpv_dip_2007", 
       main=list(label="FPV 2007", cex=1.2), cuts=6, sub="", col.regions=palette_fpv, col="transparent",
        colorkey=list(labels=list(labels=c("0%", "20%", "40%", "60%", "80%"), width=5,cex=1)))
dev.off()

# FPV 2009
png(file="A2l2.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "fpv_dip_2009", 
       main=list(label="FPV 2009", cex=1.2), cuts=6, sub="", col.regions=palette_fpv, col="transparent",
       colorkey=list(labels=list(labels=c("0%", "20%", "40%", "60%", "80%"), width=5,cex=1)))
dev.off()

# FPV 2011
png(file="A2l3.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "fpv_dip_2011", 
       main=list(label="FPV 2011", cex=1.2), cuts=6, sub="", col.regions=palette_fpv, col="transparent",
       colorkey=list(labels=list(labels=c("0%", "20%", "40%", "60%", "80%"), width=5,cex=1)))
dev.off()

# FPV 2013
png(file="A2l4.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "fpv_dip_2013", 
       main=list(label="FPV 2013", cex=1.2), cuts=6, sub="", col.regions=palette_fpv, col="transparent",
       colorkey=list(labels=list(labels=c("0%", "20%", "40%", "60%", "80%", "99%"), width=5,cex=1)))
dev.off()

# FPV 2015
png(file="A2l5.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "fpv_dip_2015", 
       main=list(label="FPV 2015", cex=1.2), cuts=6, sub="", col.regions=palette_fpv, col="transparent",
       colorkey=list(labels=list(labels=c("0%", "20%", "40%", "60%", "80%"), width=5,cex=1)))
dev.off()

# FPV 2011
png(file="A2p1.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "fpv_pres_2011", 
       main=list(label="FPV 2011", cex=1.2), cuts=6, sub="", col.regions=palette_fpv, col="transparent",
       colorkey=list(labels=list(labels=c("0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%"), width=5,cex=1)))
dev.off()

# FPV 2015
png(file="A2p2.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "fpv_pres1_2015", 
       main=list(label="FPV 2015", cex=1.2), cuts=6, sub="", col.regions=palette_fpv, col="transparent",
       colorkey=list(labels=list(labels=c("0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%"), width=5,cex=1)))
dev.off()

# Cambiemos 2015
png(file="A2p3.png", units="in", width=6, height=4, res=300)
spplot(avr_shp, "pro_pres1_2015", 
       main=list(label="Cambiemos 2015", cex=1.2), cuts=6, sub="", col.regions=palette_pro, col="transparent",
       colorkey=list(labels=list(labels=c("0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%"), width=5,cex=1)))
dev.off()


## Figure A3: Moran’s I permutation tests ----

mpi.fpv_dip_07 <- moran.mc(avr_shp@data$fpv_dip_2007, wtm, zero.policy=TRUE, nsim=999) # simulation
mpi.fpv_dip_09 <- moran.mc(avr_shp@data$fpv_dip_2009, wtm, zero.policy=TRUE, nsim=999)
mpi.fpv_dip_11 <- moran.mc(avr_shp@data$fpv_dip_2011, wtm, zero.policy=TRUE, nsim=999)
mpi.fpv_dip_13 <- moran.mc(avr_shp@data$fpv_dip_2013, wtm, zero.policy=TRUE, nsim=999)
mpi.fpv_dip_15 <- moran.mc(avr_shp@data$fpv_dip_2015, wtm, zero.policy=TRUE, nsim=999)
mpi.fpv_pre_11 <- moran.mc(avr_shp@data$fpv_pres_2011, wtm, zero.policy=TRUE, nsim=999) 
mpi.fpv_pre_15 <- moran.mc(avr_shp@data$fpv_pres1_2015, wtm, zero.policy=TRUE, nsim=999)
mpi.pro_pre_15 <- moran.mc(avr_shp@data$pro_pres1_2015, wtm, zero.policy=TRUE, nsim=999)
rpi.fpv_dip_07 <- mpi.fpv_dip_07$res[1:length(mpi.fpv_dip_07$res)-1] # extract simulated values
rpi.fpv_dip_09 <- mpi.fpv_dip_07$res[1:length(mpi.fpv_dip_09$res)-1]
rpi.fpv_dip_11 <- mpi.fpv_dip_07$res[1:length(mpi.fpv_dip_11$res)-1]
rpi.fpv_dip_13 <- mpi.fpv_dip_07$res[1:length(mpi.fpv_dip_13$res)-1]
rpi.fpv_dip_15 <- mpi.fpv_dip_07$res[1:length(mpi.fpv_dip_15$res)-1]
rpi.fpv_pre_11 <- mpi.fpv_pre_11$res[1:length(mpi.fpv_pre_11$res)-1]
rpi.fpv_pre_15 <- mpi.fpv_pre_15$res[1:length(mpi.fpv_pre_15$res)-1]
rpi.pro_pre_15 <- mpi.fpv_pre_15$res[1:length(mpi.fpv_pre_15$res)-1]
dpi.fpv_dip_07 <- density(rpi.fpv_dip_07) # density
dpi.fpv_dip_09 <- density(rpi.fpv_dip_09)
dpi.fpv_dip_11 <- density(rpi.fpv_dip_11)
dpi.fpv_dip_13 <- density(rpi.fpv_dip_13)
dpi.fpv_dip_15 <- density(rpi.fpv_dip_15)
dpi.fpv_pre_11 <- density(rpi.fpv_pre_11)
dpi.fpv_pre_15 <- density(rpi.fpv_pre_15)
dpi.pro_pre_15 <- density(rpi.fpv_pre_15)

#par(mfrow=c(2,3), oma=c(4,4,4,2), las=1) # legislative vote

# FPV 2007
png(file="A3l1.png", units="in", width=4, height=2.5, res=300)
plot(dpi.fpv_dip_07, frame.plot=FALSE, main="FPV 2007", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.fpv_dip_07 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_dip_07$statistic, lwd=2, col=4)
dev.off()

# FPV 2009
png(file="A3l2.png", units="in", width=4, height=2.5, res=300)
plot(dpi.fpv_dip_09, frame.plot=FALSE, main="FPV 2009", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.fpv_dip_09 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_dip_09$statistic, lwd=2, col=4)
dev.off()

# FPV 2011
png(file="A3l3.png", units="in", width=4, height=2.5, res=300)
plot(dpi.fpv_dip_11, frame.plot=FALSE, main="FPV 2011", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.fpv_dip_11 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_dip_11$statistic, lwd=2, col=4)
dev.off()

# FPV 2013
png(file="A3l4.png", units="in", width=4, height=2.5, res=300)
plot(dpi.fpv_dip_13, frame.plot=FALSE, main="FPV 2013", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.fpv_dip_13 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_dip_13$statistic, lwd=2, col=4)
dev.off()

# FPV 2015
png(file="A3l5.png", units="in", width=4, height=2.5, res=300)
plot(dpi.fpv_dip_15, frame.plot=FALSE, main="FPV 2015", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.fpv_dip_15 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_dip_15$statistic, lwd=2, col=4)
dev.off()


#par(mfrow=c(2,3), oma=c(4,4,4,2), las=1) # presidential vote

# FPV 2011
png(file="A3p1.png", units="in", width=4, height=2.5, res=300)
plot(dpi.fpv_pre_11, frame.plot=FALSE, main="FPV 2011", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.fpv_pre_11 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_pre_11$statistic, lwd=2, col=4)
dev.off()

# FPV 2015
png(file="A3p2.png", units="in", width=4, height=2.5, res=300)
plot(dpi.fpv_pre_15, frame.plot=FALSE, main="FPV 2015", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.fpv_pre_15 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_pre_15$statistic, lwd=2, col=4)
dev.off()

# Cambiemos 2015
png(file="A3p3.png", units="in", width=4, height=2.5, res=300)
plot(dpi.pro_pre_15, frame.plot=FALSE, main="Cambiemos 2015", 
     xlab=expression('I'['sim']), 
     ylab="Density", 
     pch=19, cex.main=1, cex.lab=1.25, xlim=c(-0.3,0.9), ylim=c(0,15), lwd=2, col=2)
hist(rpi.pro_pre_15 ,freq=FALSE, add=TRUE)
abline(v=mpi.fpv_pre_15$statistic, lwd=2, col=4)
dev.off()


## Figure A4 & A5: Moran scatterplot ----
## A4 - dependent variables
## A5 - residuals

# NOTE: The moran.plot2 function below generates each individual plot for Figures A4 and A5.
# Make sure you (un)mark the proper code lines when plotting the spatial dependence (lag DV or 
# lag residuals) and the associated labels. Also, verify you are entering the correct DVs and
# soybean harvest predictor.

# moran.plot2
# function for Moran scatterplot using standardized variates
# specify variable = x
# specify spatial weights (listw object) = wfile
# all other options are hard coded (so far)
# example: moran.plot2(avr_shp@data$pro_pres1_2015, avr_shp@data$soy_hvst_2015, wtm)

moran.plot2 <- function(x, v, wfile)
{
  xname <- deparse(substitute(x))
  #zx <- (x - mean(x)) / sd(x)                    # dependent variable
  zx <- residuals(with(avr_shp@data, lm(x ~ v)))  # residuals
  wzx <- lag.listw(wfile, zx)
  morlm <- lm(wzx ~ zx)
  # get name of variable
  aa <- morlm$coefficients[1]
  mori <- morlm$coefficients[2]
  par(pty="s")
  plot(zx, wzx, 
       xlab=paste("Residuals"),                   # label your axes 
       ylab=paste("Spatial lag of residuals"),  
       cex.main=1, cex.lab=1.25, xaxs="i", yaxs="i", frame.plot=FALSE)
  abline(aa,mori, col=2)
  abline(h=0, lty=2, col=4)
  abline(v=0, lty=2, col=4)
  title("Cambiemos 2015")                         # label election 
  text(-.15,.25, paste("I =",format(round(mori,4))), cex=.75)
}

png(file="A5_CambiemosPres2015.png",     # individual A4 or A5 graph to generate
    units="in", 
    width=4, 
    height=3.5, 
    res=300)  

moran.plot2(avr_shp@data$pro_pres1_2015, # pick vote share for a party/election
            avr_shp@data$soy_hvst_2015,  # soybean harvest for that party/election
            wtm)  
dev.off()


## Table A1: Descriptive statistics (departmental level) ----

desc.dl <- subset(avr_shp@data, select=c(fpv_dip_2005, fpv_dip_2007, fpv_dip_2009, fpv_dip_2011, 
                                     fpv_dip_2013, fpv_dip_2015, fpv_pres_2011, fpv_pres1_2015, 
                                     pro_pres1_2015, soy_hvst_2007, soy_hvst_2009, soy_hvst_2011, 
                                     soy_hvst_2013, soy_hvst_2015, soy_plnt_2007, soy_plnt_2009, 
                                     soy_plnt_2011, soy_plnt_2013, soy_plnt_2015, soy_prod_2007, 
                                     soy_prod_2009, soy_prod_2011, soy_prod_2013, soy_prod_2015,
                                     soy_ylds_2007, soy_ylds_2009, soy_ylds_2011, soy_ylds_2013, 
                                     soy_ylds_2015, lockouts_ln, k_intense, eap_small,  
                                     education_01, education_10, poverty_01, poverty_10, eap_ln,
                                     rural_01, rural_10, popdens_01, popdens_10))
stargazer(desc.dl, out="A1_descd.html", type="html")


## Table A2: Descriptive statistics (provincial level) ----

avr_shp@data$blncpc_07 <- # create % changes in provincial fiscal balances
  (avr_shp@data$fbalance_07 - avr_shp@data$fbalance_06) / avr_shp@data$fbalance_06 
avr_shp@data$blncpc_09 <- 
  (avr_shp@data$fbalance_09 - avr_shp@data$fbalance_08) / avr_shp@data$fbalance_08
avr_shp@data$blncpc_11 <- 
  (avr_shp@data$fbalance_11 - avr_shp@data$fbalance_10) / avr_shp@data$fbalance_10
avr_shp@data$blncpc_13 <- 
  (avr_shp@data$fbalance_13 - avr_shp@data$fbalance_12) / avr_shp@data$fbalance_12
avr_shp@data$blncpc_15 <- 
  (avr_shp@data$fbalance_15 - avr_shp@data$fbalance_14) / avr_shp@data$fbalance_14

desc.pl <- subset(avr_shp@data, select=c(blncpc_07, blncpc_09, blncpc_11, blncpc_13, blncpc_15,
                                         align_07, align_09, align_11, align_13, align_15))
stargazer(desc.pl, out="A2_descp.html", type="html")


#### B. Robustness Checks: Alternative Measures ####

# B1. Planted hectares ----

# Table B1.1: Legislative vote and local wealth in Argentina, 2007-2009
b11m1 = errorsarlm(fpv_dip_2007 ~ soy_plnt_2007 + fpv_dip_2005 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01
                    , wtm, data=avr_shp@data, zero.policy=TRUE)
b11m2 = errorsarlm(fpv_dip_2007 ~ soy_plnt_2007 + k_intense + eap_small + fpv_dip_2005 + education_01 + poverty_01 + 
                    eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)
b11m3 = errorsarlm(fpv_dip_2009 ~ soy_plnt_2009 + fpv_dip_2007 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01  
                    , wtm, data=avr_shp@data, zero.policy=TRUE)
b11m4 = errorsarlm(fpv_dip_2009 ~ soy_plnt_2009 + k_intense + eap_small + lockouts_ln + fpv_dip_2007 + education_01 + poverty_01 + 
                    eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b11m1, b11m2, b11m3, b11m4,
          title="Legislative vote and local wealth Argentina, 2005-2009",
          #se = list(c(rse_b1m1, rse_b1m2, rse_b1m3, rse_b1m4)),
          covariate.labels=c("Soybean planted 2007", "Soybean planted 2009",  "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", "FPV vote share 2005", 
                             "Education 2001", "Poverty 2001", "Working farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2007", "FPV 2009"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          order=c(1, 6, 5, 2, 3, 4, 7, 8, 9, 10, 11, 12),
          out="B11_plnt.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table B1.2: Legislative vote and local wealth in Argentina, 2011-2015
b12m1 <- errorsarlm(fpv_dip_2011 ~ soy_plnt_2011 + fpv_dip_2009 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b12m2 <- errorsarlm(fpv_dip_2011 ~ soy_plnt_2011 + k_intense + eap_small + lockouts_ln + fpv_dip_2009 + education_10 + poverty_10 + 
                     eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b12m3 <- errorsarlm(fpv_dip_2013 ~ soy_plnt_2013 + fpv_dip_2011 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b12m4 <- errorsarlm(fpv_dip_2013 ~ soy_plnt_2013 + k_intense + eap_small + lockouts_ln + fpv_dip_2011 + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b12m5 <- errorsarlm(fpv_dip_2015 ~ soy_plnt_2015 + fpv_dip_2013 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b12m6 <- errorsarlm(fpv_dip_2015 ~ soy_plnt_2015 + k_intense + eap_small + lockouts_ln + fpv_dip_2013 + education_10 + poverty_10 + 
                     eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b12m1, b12m2, b12m3, b12m4, b12m5, b12m6, 
          title="Legislative vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_b2m1, rse_b2m2, rse_b2m3, rse_b2m4, rse_b2m5, rse_b2m6)),
          covariate.labels=c("Soybean planted 2011 (ln)", "Soybean planted 2013 (ln)", "Soybean planted 2015 (ln)", 
                             "Lockouts 2008 (ln)", "Agricultural capital", "Smallholding farms", "FPV vote share 2009", 
                             "FPV vote share 2011", "FPV vote share 2013", "Education 2010 ", "Poverty 2010", 
                             "Working farms (ln)", "Rural population", "Population density"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2013", "FPV 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="B12_plnt.html",
          order=c(1, 6, 8, 3, 4, 2, 5, 7, 9, 10, 11, 12, 13, 14),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table B1.3: Presidential vote and local wealth in Argentina, 2011-2015
b13m1 <- errorsarlm(fpv_pres_2011 ~ soy_plnt_2011 + fpv_pres_2007 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b13m2 <- errorsarlm(fpv_pres_2011 ~ soy_plnt_2011 + fpv_pres_2007 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + 
                     eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b13m3 <- errorsarlm(fpv_pres1_2015 ~ soy_plnt_2015 + fpv_pres_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b13m4 <- errorsarlm(fpv_pres1_2015 ~ soy_plnt_2015 + fpv_pres_2011 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 +
                     eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b13m5 <- errorsarlm(pro_pres1_2015 ~ soy_plnt_2015 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10, 
                   wtm, data=avr_shp@data, zero.policy=TRUE)
b13m6 <- errorsarlm(pro_pres1_2015 ~ soy_plnt_2015 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + eap_ln + 
                     rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b13m1, b13m2, b13m3, b13m4, b13m5, b13m6,
          title="Presidential vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_b3m1, rse_b3m2, rse_b3m3, rse_b3m4, rse_b3m5, rse_b3m6)),
          covariate.labels=c("Soybean planted 2011 (ln)", "Soybean planted 2015 (ln)", "Lockouts 2008 (ln)",
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", 
                             "FPV vote share 2011", "Education", "Poverty", "Farms (ln)", 
                             "Rural population (ln)", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2015", "Cambiemos 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="B13_plnt.html",
          order=c(1, 6, 5, 3, 4, 5, 2, 7, 8, 9, 10, 11, 12),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01), 
          table.placement="h!",
          type="html"
)


# B2. Produced kilograms ----

# Table B2.1: Legislative Vote and local wealth in Argentina, 2007-2009
b21m1 = errorsarlm(fpv_dip_2007 ~ soy_prod_2007 + fpv_dip_2005 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b21m2 = errorsarlm(fpv_dip_2007 ~ soy_prod_2007 + k_intense + eap_small + fpv_dip_2005 + education_01 + poverty_01 + 
                     eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)
b21m3 = errorsarlm(fpv_dip_2009 ~ soy_prod_2009 + fpv_dip_2007 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b21m4 = errorsarlm(fpv_dip_2009 ~ soy_prod_2009 + k_intense + eap_small + lockouts_ln + fpv_dip_2007 + education_01 + poverty_01 + 
                     eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b21m1, b21m2, b21m3, b21m4,
          title="Legislative vote and local wealth Argentina, 2005-2009",
          #se = list(c(rse_b2m1, rse_b2m2, rse_b2m3, rse_b2m4)),
          covariate.labels=c("Soybean product 2007", "Soybean product 2009",  "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", "FPV vote share 2005", 
                             "Education 2001", "Poverty 2001", "Working farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2007", "FPV 2009"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          order=c(1, 6, 5, 2, 3, 4, 7, 8, 9, 10, 11, 12),
          out="B21_prod.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)

# Table B2.2: Legislative vote and local wealth in Argentina, 2011-2015
b22m1 <- errorsarlm(fpv_dip_2011 ~ soy_prod_2011 + fpv_dip_2009 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b22m2 <- errorsarlm(fpv_dip_2011 ~ soy_prod_2011 + k_intense + eap_small + lockouts_ln + fpv_dip_2009 + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b22m3 <- errorsarlm(fpv_dip_2013 ~ soy_prod_2013 + fpv_dip_2011 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b22m4 <- errorsarlm(fpv_dip_2013 ~ soy_prod_2013 + k_intense + eap_small + lockouts_ln + fpv_dip_2011 + education_10 + poverty_10 + 
                       eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b22m5 <- errorsarlm(fpv_dip_2015 ~ soy_prod_2015 + fpv_dip_2013 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b22m6 <- errorsarlm(fpv_dip_2015 ~ soy_prod_2015 + k_intense + eap_small + lockouts_ln + fpv_dip_2013 + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b22m1, b22m2, b22m3, b22m4, b22m5, b22m6, 
          title="Legislative vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_b2m1, rse_b2m2, rse_b2m3, rse_b2m4, rse_b2m5, rse_b2m6)),
          covariate.labels=c("Soybean product 2011 (ln)", "Soybean product 2013 (ln)", "Soybean product 2015 (ln)", 
                             "Lockouts 2008 (ln)", "Agricultural capital", "Smallholding farms", "FPV vote share 2009", 
                             "FPV vote share 2011", "FPV vote share 2013", "Education 2010 ", "Poverty 2010", 
                             "Working farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2013", "FPV 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="B22_prod.html",
          order=c(1, 6, 8, 3, 4, 2, 5, 7, 9, 10, 11, 12, 13, 14),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table B2.3: Presidential vote and local wealth in Argentina, 2011-2015
b23m1 <- errorsarlm(fpv_pres_2011 ~ soy_prod_2011 + fpv_pres_2007 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b23m2 <- errorsarlm(fpv_pres_2011 ~ soy_prod_2011 + fpv_pres_2007 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b23m3 <- errorsarlm(fpv_pres1_2015 ~ soy_prod_2015 + fpv_pres_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b23m4 <- errorsarlm(fpv_pres1_2015 ~ soy_prod_2015 + fpv_pres_2011 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 +
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b23m5 <- errorsarlm(pro_pres1_2015 ~ soy_prod_2015 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10, 
                    wtm, data=avr_shp@data, zero.policy=TRUE)
b23m6 <- errorsarlm(pro_pres1_2015 ~ soy_prod_2015 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + eap_ln + 
                      rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b23m1, b23m2, b23m3, b23m4, b23m5, b23m6,
          title="Presidential vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_b3m1, rse_b3m2, rse_b3m3, rse_b3m4, rse_b3m5, rse_b3m6)),
          covariate.labels=c("Soybean product 2011 (ln)", "Soybean product 2015 (ln)", "Lockouts 2008 (ln)",
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", 
                             "FPV vote share 2011", "Education", "Poverty", "Farms (ln)", 
                             "Rural population (ln)", "Population density"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2015", "Cambiemos 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="B23_prod.html",
          order=c(1, 6, 5, 3, 4, 5, 2, 7, 8, 9, 10, 11, 12),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01), 
          table.placement="h!",
          type="html"
)


# B3. Yield per harvested hectare ----

# Table B3.1: Legislative vote and local wealth in Argentina, 2007-2009
b31m1 = errorsarlm(fpv_dip_2007 ~ soy_ylds_2007 + fpv_dip_2005 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b31m2 = errorsarlm(fpv_dip_2007 ~ soy_ylds_2007 + k_intense + eap_small + fpv_dip_2005 + education_01 + poverty_01 + 
                     eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)
b31m3 = errorsarlm(fpv_dip_2009 ~ soy_ylds_2009 + fpv_dip_2007 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
b31m4 = errorsarlm(fpv_dip_2009 ~ soy_ylds_2009 + k_intense + eap_small + lockouts_ln + fpv_dip_2007 + education_01 + poverty_01 + 
                     eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b31m1, b31m2, b31m3, b31m4,
          title="Legislative vote and local wealth Argentina, 2005-2009",
          #se = list(c(rse_b3m1, rse_b3m2, rse_b3m3, rse_b3m4)),
          covariate.labels=c("Soybean yield 2007", "Soybean yield 2009",  "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", "FPV vote share 2005", 
                             "Education 2001", "Poverty 2001", "Working farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2007", "FPV 2009"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          order=c(1, 6, 5, 2, 3, 4, 7, 8, 9, 10, 11, 12),
          out="B31_ylds.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table B3.2: Legislative vote and local wealth in Argentina, 2011-2015
b32m1 <- errorsarlm(fpv_dip_2011 ~ soy_ylds_2011 + fpv_dip_2009 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b32m2 <- errorsarlm(fpv_dip_2011 ~ soy_ylds_2011 + k_intense + eap_small + lockouts_ln + fpv_dip_2009 + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b32m3 <- errorsarlm(fpv_dip_2013 ~ soy_ylds_2013 + fpv_dip_2011 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b32m4 <- errorsarlm(fpv_dip_2013 ~ soy_ylds_2013 + k_intense + eap_small + lockouts_ln + fpv_dip_2011 + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b32m5 <- errorsarlm(fpv_dip_2015 ~ soy_ylds_2015 + fpv_dip_2013 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b32m6 <- errorsarlm(fpv_dip_2015 ~ soy_ylds_2015 + k_intense + eap_small + lockouts_ln + fpv_dip_2013 + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b32m1, b32m2, b32m3, b32m4, b32m5, b32m6, 
          title="Legislative vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_b3m1, rse_b3m2, rse_b3m3, rse_b3m4, rse_b3m5, rse_b3m6)),
          covariate.labels=c("Soybean yield 2011 (ln)", "Soybean yield 2013 (ln)", "Soybean yield 2015 (ln)", 
                             "Lockouts 2008 (ln)", "Agricultural capital", "Smallholding farms", "FPV vote share 2009", 
                             "FPV vote share 2011", "FPV vote share 2013", "Education 2010 ", "Poverty 2010", 
                             "Working farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2013", "FPV 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="B32_ylds.html",
          order=c(1, 6, 8, 3, 4, 2, 5, 7, 9, 10, 11, 12, 13, 14),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table B3.3: Presidential vote and local wealth in Argentina, 2011-2015
b33m1 <- errorsarlm(fpv_pres_2011 ~ soy_ylds_2011 + fpv_pres_2007 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b33m2 <- errorsarlm(fpv_pres_2011 ~ soy_ylds_2011 + fpv_pres_2007 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + 
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b33m3 <- errorsarlm(fpv_pres1_2015 ~ soy_ylds_2015 + fpv_pres_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                      , wtm, data=avr_shp@data, zero.policy=TRUE)
b33m4 <- errorsarlm(fpv_pres1_2015 ~ soy_ylds_2015 + fpv_pres_2011 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 +
                      eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
b33m5 <- errorsarlm(pro_pres1_2015 ~ soy_ylds_2015 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10, 
                    wtm, data=avr_shp@data, zero.policy=TRUE)
b33m6 <- errorsarlm(pro_pres1_2015 ~ soy_ylds_2015 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + eap_ln + 
                      rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(b33m1, b33m2, b33m3, b33m4, b33m5, b33m6,
          title="Presidential vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_b3m1, rse_b3m2, rse_b3m3, rse_b3m4, rse_b3m5, rse_b3m6)),
          covariate.labels=c("Soybean yield 2011 (ln)", "Soybean yield 2015 (ln)", "Lockouts 2008 (ln)",
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", 
                             "FPV vote share 2011", "Education", "Poverty", "Farms (ln)", 
                             "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2015", "Cambiemos 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="B33_ylds.html",
          order=c(1, 6, 5, 3, 4, 5, 2, 7, 8, 9, 10, 11, 12),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01), 
          table.placement="h!",
          type="html"
)


#### C. Sensitivity Analysis ####

## C1. Spatial lag ----

# Table C1.1: Legislative vote and local wealth in Argentina, 2007-2009
c11m1 = lagsarlm(fpv_dip_2007 ~ soy_hvst_2007 + fpv_dip_2005 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01 
                    , wtm, data=avr_shp@data, zero.policy=TRUE)
c11m2 = lagsarlm(fpv_dip_2007 ~ soy_hvst_2007 + k_intense + eap_small + fpv_dip_2005 + education_01 + poverty_01 + 
                    eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)
c11m3 = lagsarlm(fpv_dip_2009 ~ soy_hvst_2009 + fpv_dip_2007 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01
                    , wtm, data=avr_shp@data, zero.policy=TRUE)
c11m4 = lagsarlm(fpv_dip_2009 ~ soy_hvst_2009 + k_intense + eap_small + lockouts_ln + fpv_dip_2007 + education_01 + poverty_01 + 
                    eap_ln + rural_01 + popdens_01, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(c11m1, c11m2, c11m3, c11m4,
          title="Legislative vote and local wealth Argentina, 2005-2009",
          #se = list(c(rse_c1m1, rse_c1m2, rse_c1m3, rse_c1m4)),
          covariate.labels=c("Soybean harvest 2007", "Soybean harvest 2009",  "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", "FPV vote share 2005", 
                             "Education 2001", "Poverty 2001", "Working farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2007", "FPV 2009"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          order=c(1, 6, 5, 2, 3, 4, 7, 8, 9, 10, 11, 12),
          out="C11_SL.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table C1.2: Legislative vote and local wealth in Argentina, 2011-2015
c12m1 <- lagsarlm(fpv_dip_2011 ~ soy_hvst_2011 + fpv_dip_2009 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                  , wtm, data=avr_shp@data, zero.policy=TRUE)
c12m2 <- lagsarlm(fpv_dip_2011 ~ soy_hvst_2011 + k_intense + eap_small + lockouts_ln + fpv_dip_2009 + education_10 + poverty_10 + 
                  eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
c12m3 <- lagsarlm(fpv_dip_2013 ~ soy_hvst_2013 + fpv_dip_2011 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                  , wtm, data=avr_shp@data, zero.policy=TRUE)
c12m4 <- lagsarlm(fpv_dip_2013 ~ soy_hvst_2013 + k_intense + eap_small + lockouts_ln + fpv_dip_2011 + education_10 + poverty_10 + 
                  eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
c12m5 <- lagsarlm(fpv_dip_2015 ~ soy_hvst_2015 + fpv_dip_2013 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                  , wtm, data=avr_shp@data, zero.policy=TRUE)
c12m6 <- lagsarlm(fpv_dip_2015 ~ soy_hvst_2015 + k_intense + eap_small + lockouts_ln + fpv_dip_2013 + education_10 + poverty_10 + 
                  eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(c12m1, c12m2, c12m3, c12m4, c12m5, c12m6, 
          title="Legislative vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_c2m1, rse_c2m2, rse_c2m3, rse_c2m4, rse_c2m5, rse_c2m6)),
          covariate.labels=c("Soybean harvest 2011 (ln)", "Soybean harvest 2013 (ln)", "Soybean harvest 2015 (ln)", 
                             "Lockouts 2008 (ln)", "Agricultural capital", "Smallholding farms", "FPV vote share 2009", 
                             "FPV vote share 2011", "FPV vote share 2013", "Education 2010 ", "Poverty 2010", 
                             "Working farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2013", "FPV 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="C12_SL.html",
          order=c(1, 6, 8, 3, 4, 2, 5, 7, 9, 10, 11, 12, 13, 14),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table C1.3: Presidential vote and local wealth in Argentina, 2011-2015
c13m1 <- lagsarlm(fpv_pres_2011 ~ soy_hvst_2011 + fpv_pres_2007 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                  , wtm, data=avr_shp@data, zero.policy=TRUE)
c13m2 <- lagsarlm(fpv_pres_2011 ~ soy_hvst_2011 + fpv_pres_2007 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + 
                  eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
c13m3 <- lagsarlm(fpv_pres1_2015 ~ soy_hvst_2015 + fpv_pres_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10
                     , wtm, data=avr_shp@data, zero.policy=TRUE)
c13m4 <- lagsarlm(fpv_pres1_2015 ~ soy_hvst_2015 + fpv_pres_2011 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 +
                    eap_ln + rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)
c13m5 <- lagsarlm(pro_pres1_2015 ~ soy_hvst_2015 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10, 
                 wtm, data=avr_shp@data, zero.policy=TRUE)
c13m6 <- lagsarlm(pro_pres1_2015 ~ soy_hvst_2015 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + eap_ln + 
                   rural_10 + popdens_10, wtm, data=avr_shp@data, zero.policy=TRUE)

stargazer(c13m1, c13m2, c13m3, c13m4, c13m5, c13m6,
          title="Presidential vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_c3m1, rse_c3m2, rse_c3m3, rse_c3m4, rse_c3m5, rse_c3m6)),
          covariate.labels=c("Soybean harvest 2011 (ln)", "Soybean harvest 2015 (ln)", "Lockouts 2008 (ln)",
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", 
                             "FPV vote share 2011", "Education", "Poverty", "Farms (ln)", 
                             "Rural population (ln)", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2015", "Cambiemos 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          out="C13_SL.html",
          order=c(1, 6, 5, 3, 4, 5, 2, 7, 8, 9, 10, 11, 12),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01), 
          table.placement="h!",
          type="html"
)


## C2. Random intercepts ----

# Table C2.1: Legislative vote and local wealth in Argentina, 2007-2009
c21m1 <- lmer(fpv_dip_2007 ~ soy_hvst_2007 + k_intense + eap_small + fpv_dip_2005 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01 + 
                (1 | NAME_1), data=avr_shp@data)
c21m2 <- lmer(fpv_dip_2007 ~ soy_hvst_2007 + k_intense + eap_small + blncpc_07 + align_07 + fpv_dip_2005 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01 + 
                (1 | NAME_1), data=avr_shp@data)
c21m3 <- lmer(fpv_dip_2009 ~ soy_hvst_2009 + lockouts_ln + k_intense + eap_small + fpv_dip_2007 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01 + 
                (1 | NAME_1), data=avr_shp@data)
c21m4 <- lmer(fpv_dip_2009 ~ soy_hvst_2009 + lockouts_ln + k_intense + eap_small + blncpc_09 + align_09 + fpv_dip_2007 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01 + 
                (1 | NAME_1), data=avr_shp@data)

stargazer(c21m1, c21m2, c21m3, c21m4,
          title="Legislative vote and local wealth Argentina, 2007-2009",
          #se = list(c(rse_c2m1, rse_c2m2, rse_c2m3, rse_c2m4)),
          covariate.labels=c("Soybean harvest 2007", "Soybean harvest 2009",  "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "Provincial fiscal balance 2007", "Provincial fiscal balance 2009",
                             "Governor alignment 2007", "Governor alignment 2009", "FPV vote share 2005", "FPV vote share 2007", 
                             "Education 2001", "Poverty 2001", "Farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2007", "FPV 2009"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          order=c(1, 2, 3, 4, 5, 6, 9, 7, 10, 8, 11, 12, 13, 14, 15),
          out="C21_RI.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table C2.2: Legislative vote and local wealth in Argentina, 2011-2015
c22m1 <- lmer(fpv_dip_2011 ~ soy_hvst_2011 + lockouts_ln + k_intense + eap_small + fpv_dip_2009 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c22m2 <- lmer(fpv_dip_2011 ~ soy_hvst_2011 + lockouts_ln + k_intense + eap_small + blncpc_11 + align_11 + fpv_dip_2009 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c22m3 <- lmer(fpv_dip_2013 ~ soy_hvst_2013 + lockouts_ln + k_intense + eap_small + fpv_dip_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c22m4 <- lmer(fpv_dip_2013 ~ soy_hvst_2013 + lockouts_ln + k_intense + eap_small + blncpc_13 + align_13 + fpv_dip_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c22m5 <- lmer(fpv_dip_2015 ~ soy_plnt_2015 + lockouts_ln + k_intense + eap_small + fpv_dip_2013 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c22m6 <- lmer(fpv_dip_2015 ~ soy_plnt_2015 + lockouts_ln + k_intense + eap_small + blncpc_15 + align_15 + fpv_dip_2013 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)

stargazer(c22m1, c22m2, c22m3, c22m4, c22m5, c22m6, 
          title="Legislative vote and local wealth Argentina, 2011-2015",
          #se = list(c(rse_c2m1, rse_c2m2, rse_c2m3, rse_c2m4)),
          covariate.labels=c("Soybean harvest 2011 (ln)", "Soybean harvest 2013 (ln)", "Soybean harvest 2015 (ln)", "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "Provincial fiscal balance 2011", "Provincial fiscal balance 2013",
                             "Provincial fiscal balance 2015", "Governor alignment 2011", "Governor alignment 2013", "Governor alignment 2015", 
                             "FPV vote share 2009", "FPV vote share 2011", "FPV vote share 2013", "Education", "Poverty", "Farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2011", "FPV 2013", "FPV 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          order=c(1, 2, 3, 4, 5, 6, 7, 10, 11, 8, 12, 9, 13, 14, 15, 16, 17, 18, 19),
          out="C22_RI.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table C2.3: Presidential vote and local wealth in Argentina, 2011-2015
c23m1 <- lmer(fpv_pres_2011 ~ soy_hvst_2011 + lockouts_ln + k_intense + eap_small + fpv_pres_2007 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c23m2 <- lmer(fpv_pres_2011 ~ soy_hvst_2011 + lockouts_ln + k_intense + eap_small +  blncpc_11 + align_11 + fpv_pres_2007 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c23m3 <- lmer(fpv_pres1_2015 ~ soy_hvst_2015 + lockouts_ln + k_intense + eap_small + fpv_pres_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c23m4 <- lmer(fpv_pres1_2015 ~ soy_hvst_2015 + lockouts_ln + k_intense + eap_small + blncpc_15 + align_15 + fpv_pres_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c23m5 <- lmer(pro_pres1_2015 ~ soy_hvst_2015 + lockouts_ln + k_intense + eap_small + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)
c23m6 <- lmer(pro_pres1_2015 ~ soy_hvst_2015 + lockouts_ln + k_intense + eap_small + blncpc_15 + align_15 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 + 
                (1 | NAME_1), data=avr_shp@data)

stargazer(c23m1, c23m2, c23m3, c23m4, c23m5, c23m6, 
          title="Presidential vote and local wealth Argentina, 2011-2015",
          #se = list(c(rse_c2m1, rse_c2m2, rse_c2m3, rse_c2m4)),
          covariate.labels=c("Soybean harvest 2011 (ln)", "Soybean harvest 2015 (ln)", "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "Provincial fiscal balance 2011",
                             "Provincial fiscal balance 2015", "Governor alignment 2011", "Governor alignment 2015", 
                             "FPV vote share 2007", "FPV vote share 2011", "Education", "Poverty", "Farms (ln)", "Rural population", "Population density (ln)"),
          #add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2011", "FPV 2015", "Cambiemos 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="province",
          omit.stat="f",
          order=c(1, 2, 3, 4, 5, 6, 9, 7, 10, 8, 11, 12, 13, 14, 15, 16),
          out="C23_RI.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


## C3. Spatial fixed effects ----

# Table C3.1: Legislative vote and local wealth in Argentina, 2007-2009
c31m1 = lm(fpv_dip_2007 ~ soy_hvst_2007 + fpv_dip_2005 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01 +
             factor(NAME_1), data=avr_shp@data)
c31m2 = lm(fpv_dip_2007 ~ soy_hvst_2007 + k_intense + eap_small + fpv_dip_2005 + education_01 + poverty_01 + 
             eap_ln + rural_01 + popdens_01 + factor(NAME_1), data=avr_shp@data)
c31m3 = lm(fpv_dip_2009 ~ soy_hvst_2009 + fpv_dip_2007 + education_01 + poverty_01 + eap_ln + rural_01 + popdens_01 +
             factor(NAME_1), data=avr_shp@data)
c31m4 = lm(fpv_dip_2009 ~ soy_hvst_2009 + k_intense + eap_small + lockouts_ln + fpv_dip_2007 + education_01 + poverty_01 + 
             eap_ln + rural_01 + popdens_01 + factor(NAME_1), data=avr_shp@data)

stargazer(c31m1, c31m2, c31m3, c31m4,
          title="Legislative vote and local wealth Argentina, 2005-2009",
          #se = list(c(rse_c2m1, rse_c2m2, rse_c2m3, rse_c2m4)),
          covariate.labels=c("Soybean harvest 2007", "Soybean harvest 2009",  "Lockouts 2008 (ln)", 
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", "FPV vote share 2005", 
                             "Education 2001", "Poverty 2001", "Working farms (ln)", "Rural population", "Population density (ln)"),
          add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES")),
          column.sep.width="2pt",
          dep.var.labels=c("FPV 2007", "FPV 2009"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          no.space=TRUE,
          omit="NAME_1",
          omit.stat="f",
          order=c(1, 6, 5, 2, 3, 4, 7, 8, 9, 10, 11, 12),
          out="C31_FE.html",
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table C3.2: Legislative vote and local wealth in Argentina, 2011-2015
c32m1 <- lm(fpv_dip_2011 ~ soy_hvst_2011 + fpv_dip_2009 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 +
              factor(NAME_1), data=avr_shp@data)
c32m2 <- lm(fpv_dip_2011 ~ soy_hvst_2011 + k_intense + eap_small + lockouts_ln + fpv_dip_2009 + education_10 + poverty_10 + 
              eap_ln + rural_10 + popdens_10 + factor(NAME_1), data=avr_shp@data)
c32m3 <- lm(fpv_dip_2013 ~ soy_hvst_2013 + fpv_dip_2011 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 +
              factor(NAME_1), data=avr_shp@data)
c32m4 <- lm(fpv_dip_2013 ~ soy_hvst_2013 + k_intense + eap_small + lockouts_ln + fpv_dip_2011 + education_10 + poverty_10 + 
              eap_ln + rural_10 + popdens_10 + factor(NAME_1), data=avr_shp@data)
c32m5 <- lm(fpv_dip_2015 ~ soy_hvst_2015 + fpv_dip_2013 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 +
              factor(NAME_1), data=avr_shp@data)
c32m6 <- lm(fpv_dip_2015 ~ soy_hvst_2015 + k_intense + eap_small + lockouts_ln + fpv_dip_2013 + education_10 + poverty_10 + 
              eap_ln + rural_10 + popdens_10 + factor(NAME_1), data=avr_shp@data)

stargazer(c32m1, c32m2, c32m3, c32m4, c32m5, c32m6, 
          title="Legislative vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_c2m1, rse_c2m2, rse_c2m3, rse_c2m4, rse_c2m5, rse_c2m6)),
          covariate.labels=c("Soybean harvest 2011 (ln)", "Soybean harvest 2013 (ln)", "Soybean harvest 2015 (ln)", 
                             "Lockouts 2008 (ln)", "Agricultural capital", "Smallholding farms", "FPV vote share 2009", 
                             "FPV vote share 2011", "FPV vote share 2013", "Education 2010 ", "Poverty 2010", 
                             "Working farms (ln)", "Rural population", "Population density (ln)"),
          add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2013", "FPV 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="NAME_1",
          omit.stat="f",
          out="C32_FE.html",
          order=c(1, 6, 8, 3, 4, 2, 5, 7, 9, 10, 11, 12, 13, 14),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01),
          table.placement="h!",
          type="html"
)


# Table C3.3: Presidential vote and local wealth in Argentina, 2011-2015
c33m1 <- lm(fpv_pres_2011 ~ soy_hvst_2011 + fpv_pres_2007 +  education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 +
              factor(NAME_1), data=avr_shp@data)
c33m2 <- lm(fpv_pres_2011 ~ soy_hvst_2011 + fpv_pres_2007 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + 
              eap_ln + rural_10 + popdens_10 + factor(NAME_1), data=avr_shp@data)
c33m3 <- lm(fpv_pres1_2015 ~ soy_hvst_2015 + fpv_pres_2011 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 +
              factor(NAME_1), data=avr_shp@data)
c33m4 <- lm(fpv_pres1_2015 ~ soy_hvst_2015 + fpv_pres_2011 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 +
              eap_ln + rural_10 + popdens_10 + factor(NAME_1), data=avr_shp@data)
c33m5 <- lm(pro_pres1_2015 ~ soy_hvst_2015 + education_10 + poverty_10 + eap_ln + rural_10 + popdens_10 +
              factor(NAME_1), data=avr_shp@data)
c33m6 <- lm(pro_pres1_2015 ~ soy_hvst_2015 + k_intense + eap_small + lockouts_ln + education_10 + poverty_10 + eap_ln + 
              rural_10 + popdens_10 + factor(NAME_1), data=avr_shp@data)

stargazer(c33m1, c33m2, c33m3, c33m4, c33m5, c33m6,
          title="Presidential vote and local wealth in Argentina, 2011-2015",
          #se = list(c(rse_c3m1, rse_c3m2, rse_c3m3, rse_c3m4, rse_c3m5, rse_c3m6)),
          covariate.labels=c("Soybean harvest 2011 (ln)", "Soybean harvest 2015 (ln)", "Lockouts 2008 (ln)",
                             "Agricultural capital", "Smallholding farms", "FPV vote share 2007", 
                             "FPV vote share 2011", "Education", "Poverty", "Farms (ln)", 
                             "Rural population (ln)", "Population density (ln)"),
          add.lines=list(c("Fixed effects", "YES", "YES", "YES", "YES", "YES", "YES")),
          column.sep.width="-5pt",
          dep.var.labels=c("FPV 2011", "FPV 2015", "Cambiemos 2015"),
          dep.var.labels.include=TRUE,
          digits=3,
          float=TRUE,
          #float.env="sidewaystable",
          font.size="small",
          no.space=TRUE,
          omit="NAME_1",
          omit.stat="f",
          out="C33_FE.html",
          order=c(1, 6, 5, 3, 4, 5, 2, 7, 8, 9, 10, 11, 12),
          single.row=FALSE,
          star.cutoffs = c(0.10, 0.05, 0.01), 
          table.placement="h!",
          type="html"
)

